package cn.echogo.framework.http.imp;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.nio.charset.Charset;

import org.apache.http.util.CharArrayBuffer;

import com.google.gson.Gson;

import android.util.Log;

import cn.echogo.framework.http.ResponseEntity;

public class JsonResponseEntity implements ResponseEntity {
	
	private String json;
	private int resultCode;
	private String errorCode;
	
	public JsonResponseEntity(InputStream inputStream, String charset, int length) throws IOException {
        Reader reader = new InputStreamReader(inputStream, charset);
        CharArrayBuffer buffer = new CharArrayBuffer(length); 
        try {
            char[] tmp = new char[1024];
            int l;
            while((l = reader.read(tmp)) != -1) {
                buffer.append(tmp, 0, l);
            }
        } finally {
            reader.close();
        }
        json = buffer.toString();
        System.out.println("json = " + json);
        
        parseInternal();
	}
	
	private void parseInternal() {
		
	}
	

	
	//{"result":0,"data":"","errno":"MBCE1005","errmsg":"please enter login email\/member ID and login password!","ext":""}

	@Override
	public int getResultCode() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getErrorCode() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getMessage() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public InputStream getDataStream() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getDataText() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getDataText(String charsetName) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> T getData(Class<T> clazz) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> T getData(Type type) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> T getData(String key, Class<T> clazz) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> T getData(String key, Type type) {
		// TODO Auto-generated method stub
		return null;
	}

}
